package com.basics.framework.security.handle;//package com.basics.framework.security.handle;
//
//
//import com.alibaba.fastjson.JSON;
//import com.basics.user.utils.ServletUtils;
//import com.basics.user.utils.StringUtils;
//import com.basics.framework.manager.AsyncManager;
//import com.basics.framework.manager.factory.AsyncFactory;
//import com.basics.framework.web.domain.RestResult;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
//@Configuration
//public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler {
//    @Autowired
//    private TokenService tokenService;
//
//    public LogoutSuccessHandlerImpl() {
//    }
//
//    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
//        LoginUser loginUser = this.tokenService.getLoginUser(request);
//        if (StringUtils.isNotNull(loginUser)) {
//            String userName = loginUser.getUsername();
//            this.tokenService.delLoginUser(loginUser.getToken());
//            AsyncManager.me().execute(AsyncFactory.recordLogininfor(userName, "Logout", "退出成功", new Object[0]));
//        }
//
//        ServletUtils.renderString(response, JSON.toJSONString(RestResult.error(200, "退出成功")));
//    }
//}
//
